from os.path import join 
from os import getcwd

import xlsxwriter

from extracts import classes_pc, classes_dict

xlsx_file = join(getcwd(), "classes.xlsx")

pc = classes_pc()
dict = classes_dict()
dict_codes = dict['codes']
codes=[]
for item in dict_codes:
	codes+=[[item, dict_codes[item]]]
dict_names = dict['names']
names=[]
for item in dict_names:
	names+=[[item, dict_names[item]]]

pc_heads=['parent', 'child']
code_heads=['code', 'name']
name_heads=['name', 'code']

workbook = xlsxwriter.Workbook(xlsx_file)
pcsheet = workbook.add_worksheet('pc tree')
codesheet = workbook.add_worksheet('dict code')
namesheet = workbook.add_worksheet('dict names')

lh=len(pc_heads)
lr=len(pc)

for x in range(lh):
	pcsheet.write(0, x, pc_heads[x])
for y in range(lr):
	for z in range(lh):
		pcsheet.write(1+y, z, pc[y][z])

lh=len(code_heads)
lr=len(codes)

for x in range(lh):
	codesheet.write(0, x, code_heads[x])
for y in range(lr):
	for z in range(lh):
		codesheet.write(1+y, z, codes[y][z])

lh=len(name_heads)
lr=len(names)

for x in range(lh):
	namesheet.write(0, x, name_heads[x])
for y in range(lr):
	for z in range(lh):
		namesheet.write(1+y, z, names[y][z])

		
workbook.close()